<template>
<div>
  <!-- 用户已登陆 -->
  <div class="ok">
    <!-- 用户头像与名称 -->
    <div class="user">
        <image class="img" :src="userInfo.avatarUrl"/>
        <div class="name">
          你好,管理员
          <div style="color:gray">{{userInfo.nickName}}</div>
        </div>
     </div>
  </div>
  <i-button class="button" @tap="addgoods" type="success">增加商品</i-button>
  <i-button class="button" @tap="changegoods" type="warning">删除或更改商品</i-button>
 </div>
</template>

<script>
export default {
  data () {
    return {
      userInfo: {},
      openid: '',
      admin: false

    }
  },
  beforeMount () {
    this.handleGetUserInfo()
  },
  methods: {
    handleGetUserInfo () {
      wx.getUserInfo({
        success: (data) => {
          console.log(data)
          this.userInfo = data.userInfo
          this.isShow = true
        },
        fail: () => {
          console.log('获取失败')
        }
      })
    },
    addgoods () {
      wx.navigateTo({
        url: '../../pages/goodsadd/main'
      })
    },
    changegoods () {
      wx.navigateTo({
        url: '../../pages/goodschange/main'
      })
    }
  },

  created () {
    // let app = getApp()
  }
}
</script>

<style scoped>
/* 用户样式 */
.user{
  flex: 1;
  display: flex;
  position: relative;
  height: 250rpx;
  border-top: 2px solid gray;
  border-bottom: 2px solid gray;
}

.img{
  width: 200rpx;
  height: 200rpx;
  border-radius: 50%;
  margin-left: 50rpx;
  margin-top: 25rpx;
}
.name{
  margin-left: 30rpx;
  margin-top:30rpx;
}
.button{
  margin-top: 20rpx;
}
</style>
